package com.bank.backend.boot.server.controller;


import com.bank.backend.boot.base.model.dto.UserDTO;
import com.bank.backend.boot.base.model.vo.UserVO;
import com.bank.backend.boot.server.annotation.ResponseResult;
import com.bank.backend.boot.server.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiaowei
 * @since 2025/3/29 21:08
 */
@Slf4j
@Tag(name = "用户信息")
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 保存用户信息
     * @param userDTO
     * @return
     */
    @Operation(summary = "保存用户信息")
    @PostMapping("/saveUser")
    @ResponseResult
    public Boolean saveUser(@RequestBody UserDTO userDTO) {
        return userService.saveUser(userDTO);
    }

    @Operation(summary = "查询所有用户信息")
    @GetMapping("/queryUserList")
    @ResponseResult
    public List<UserVO> queryUserList() {
        return userService.queryUserList();
    }

    @Operation(summary = "根据id查询用户信息")
    @GetMapping("/queryUserById/{id}")
    @ResponseResult
    public UserVO queryUserById(@PathVariable("id") Long id) {
        return userService.queryUserById(id);
    }

    @Operation(summary = "分页查询用户信息")
    @GetMapping("/queryUserPage/{currentPage}/{pageSize}")
    @ResponseResult
    public Page<UserVO> queryUserPage(@PathVariable(value = "currentPage") int currentPage, @PathVariable(value = "pageSize") int pageSize) {
        return userService.queryUserPage(currentPage, pageSize);
    }

}
